import { useingCardNum ,amountQuery} from "@/api/system/info";
const state = {
	allCardInfo:{  //所有的卡信息
		allCount:undefined,
		status0:'',
		status1:'',
		status2:'',
		status3:'',
		status4:'',
		status5:'',
		status6:'',
		liantongMoney:'',
		aliMoney:'',
		mingqianMoney:'',
		money:'',
		role:''
	}
}

const mutations = {
	UPDATA_ALLCARDINFO(state,data){  
		state.allCardInfo.liantongMoney = data.liantongMoney;
		state.allCardInfo.aliMoney = data.aliMoney;
		state.allCardInfo.mingqianMoney = data.mingqianMoney;
		state.allCardInfo.money = data.money;
		state.allCardInfo.role = data.role;
		state.allCardInfo.allCount = data.cardNum.allCount;
		state.allCardInfo.status0 = data.cardNum.status0;
		state.allCardInfo.status1 = data.cardNum.status1;
		state.allCardInfo.status2 = data.cardNum.status2;
		state.allCardInfo.status3 = data.cardNum.status3;
		state.allCardInfo.status4 = data.cardNum.status4;
		state.allCardInfo.status5 = data.cardNum.status5;
		state.allCardInfo.status6 = data.cardNum.status6;
	},
}

const actions = {  
	updataAllCardInfo({commit}){//手机号
//		var allCardInfonData = {};
//		judgeRole().then((res)=>{  //判断角色
//			var judgeRoleType =res.result;
//			amountQuery().then((res)=>{
//	  		if(judgeRoleType.manager){  //如果是管理员
//	  		 allCardInfonData.amountMoney = '***';
//	  		}else{
//	  			allCardInfonData.amountMoney = res.data;
//	  		}
//	  		useingCardNum().then((res)=>{
//			//		卡状态             0：其他 1：待激活2：沉默期（库存） 3：测试期 4：正常 5：停机 6：已销号
//			allCardInfonData.cardNum = res.data;
//			commit('UPDATA_ALLCARDINFO',allCardInfonData);
//		  	})
//	  		})
//		})
		
		var allCardInfonData = {};
			amountQuery().then((res)=>{
				console.log(res);
	  		if(res.data.role=='admin'){  //如果是管理员
	  		 allCardInfonData.liantongMoney = res.data.liantongMoney;
	  		 allCardInfonData.aliMoney = res.data.aliMoney;
	  		 allCardInfonData.mingqianMoney = res.data.mingqianMoney;
	  		}else{
	  			if(res.data.money){
	  				allCardInfonData.money = res.data.money.money;
	  			}
	  		}
	  		 	allCardInfonData.role = res.data.role;
		  		useingCardNum().then((res)=>{
				//		卡状态             0：其他 1：待激活2：沉默期（库存） 3：测试期 4：正常 5：停机 6：已销号
				allCardInfonData.cardNum = res.data;
				commit('UPDATA_ALLCARDINFO',allCardInfonData);
			  	})
	  		})
	},
}


export default {
  namespaced: true,
  state,
  mutations,
  actions
}
